

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class PageViewPage2 extends StatefulWidget {
  const PageViewPage2({super.key});
  @override
  State<PageViewPage2> createState() => _PageViewPageState();
}
class _PageViewPageState extends State<PageViewPage2> {
  int itemCount=10;
  @override
  void initState() {
// TODO: implement initState
    super.initState();
  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: const Text("pageview演示"),
        ),
        body: PageView.builder(
          scrollDirection: Axis.vertical, // 滑动方向为垂直方向
          itemBuilder: (BuildContext context, int index) {
           // return MyPage(text:"$index");
         //   return Text('content  $index');
            return Center(
              child: Text('content   $index',style: Theme.of(context).textTheme.headline1),
            );;
          },
          itemCount: 10,
        ));
  }
}
class MyPage extends StatefulWidget {
  final String text;
  const MyPage({super.key,required this.text});
  @override
  State<MyPage> createState() => _MyPageState();
}
class _MyPageState extends State<MyPage> {
  @override
  Widget build(BuildContext context) {
    return Center(
      child: Text(widget.text,style: Theme.of(context).textTheme.headline1),
    );
  }
}

